package com.example.myproject.service;

import com.example.myproject.model.Contract;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

public interface ContractService {
    // 根据合同名称和状态搜索合同
    List<Contract> searchContractsByNameAndStatus(String name, int status);

    // 得到所有合同
    List<Contract> getAllContracts();

    // 查找合同
    List<Contract> searchContractsByName(String name);

    // 删除合同
    void deleteContract(String name);

    // 起草合同

    @Transactional(rollbackFor = Exception.class)
    Contract draft(Contract contract, String username);

    // 更新会签意见
    Contract updateCounterSignOpinion(String contractName, String opinion);


    // 更新审批意见
    @Transactional
    Contract updateApprovalOpinion(String contractName, String opinion, String status);

    // 更新签订意见
    @Transactional
    Contract updateSignOpinion(String contractName, String signInfo);

    // 定稿合同
    Contract finalizeContract(String contractName, String content);

    // 处理合同审批
    Contract approveContract(String contractName, String opinion, String status);

    // 根据合同名称获取合同的ID
    Long getContractIdByName(String contractName);

    // 通过合同名称获取合同的详细信息
    Optional<Contract> getContractDetailsByName(String contractName);

    // 获取待会签的合同列表
    List<Contract> findContractsByStatus(int status);

    // 签订合同
    Contract signContract(String contractName, String signInfo);

    // 添加合同分配方法
    boolean assignContract(Long contractId, List<Long> countersignUserIds, List<Long> approvalUserIds, List<Long> signingUserIds);

    @Transactional
    Contract save(Contract contract);


    void assignContractByName(String contractName, List<Long> countersignUserIds, List<Long> approvalUserIds, List<Long> signingUserIds);
}


